#ifndef TESTFUNCTIONS_H_INCLUDED
#define TESTFUNCTIONS_H_INCLUDED

#include "cekla.h"

/**
 * Testing functions
 */

template<typename functype, typename argtype>
void test(const char* fname, const functype fp, const argtype arg) {
    write(fname);
    write("( ");
    write(arg);
    writeln(" ):");
    write(" ");
    writeln(fp(arg));
}

template<typename functype, typename argtype1, typename argtype2>
void test(const char* fname, const functype fp, const argtype1 arg1, const argtype2 arg2) {
    write(fname);
    write("( ");
    write(arg1);
    write(", ");
    write(arg2);
    writeln(" ):");
    write(" ");
    writeln(fp(arg1, arg2));
}

template<typename functype, typename argtype1, typename argtype2, typename argtype3>
void test(const char* fname, const functype fp, const argtype1 arg1, const argtype2 arg2, const argtype3 arg3) {
    write(fname);
    write("( ");
    write(arg1);
    write(", ");
    write(arg2);
    write(", ");
    write(arg3);
    writeln(" ):");
    write(" ");
    writeln(fp(arg1, arg2, arg3));
}

template<typename functype, typename argtype1, typename argtype2>
void running_second_arg_test(const char* fname, const functype fp, const argtype1 arg1, const argtype2 arg2_min, const argtype2 arg2_max) {
    argtype2 arg2 = arg2_min;
    do {
        test(fname, fp, arg1, arg2);
    } while (++arg2 <= arg2_max);
}

template<typename functype, typename argtype1, typename argtype2, typename argtype3>
void running_second_arg_test(const char* fname, const functype fp, const argtype1 arg1, const argtype2 arg2_min, const argtype2 arg2_max, const argtype3 arg3) {
    argtype2 arg2 = arg2_min;
    do {
        test(fname, fp, arg1, arg2, arg3);
    } while (++arg2 <= arg2_max);
}

template<typename functype, typename argtype1, typename argtype2, typename argtype3>
void running_second_and_third_arg_test(const char* fname, const functype fp, const argtype1 arg1, const argtype2 arg2_min, const argtype2 arg2_max, const argtype3 arg3_min, const argtype3 arg3_max) {
    argtype2 arg3 = arg3_min;
    do {
        running_second_arg_test(fname, fp, arg1, arg2_min, arg2_max, arg3);
    } while (++arg3 <= arg3_max);
}

#endif // TESTFUNCTIONS_H_INCLUDED
